<template>
    <div>
        <div class="add_title"><b>店铺信息</b></div>
        <div>
            <h2>店铺名称:{{ shopInfo.shopname }} 编号:{{ shopInfo.shopCode }}</h2>
            <p>店铺地址:北京市海淀区中关村大街1号</p>
            <p>店铺创建时间:{{ shopInfo.createtime }}</p>
            <p>店铺电话:010-12345678</p>
            <p>店铺介绍:{{ shopInfo.shopInfo }}</p>
            <el-upload :data="{ id: shopInfo.shopid }" :action="action" :headers="headers" :show-file-list="false"
                :on-success="uploadsuccess">
                <el-avatar shape="square" :size="80" :src="shopInfo.s_imgurl"></el-avatar>
            </el-upload>

        </div>
    </div>
</template>

<script setup>
//引入
import { ref } from "vue";
import { baseURL } from "@/config/config";
import { $_shopInfo } from '@/apis/shop';
import { UseuserInfo } from "@/store/user.js";
import { baseImgURL } from "@/config/config";


// 声明变量
const delImgUrl = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
const action = ref(`${baseURL}/shop/uploadimg`)
const shopInfo = ref('')
let { userInfo, token } = UseuserInfo()
let shopid = userInfo.sid
const headers = ref({
    Authorization: token,
    ContentType: 'application/json'
})

// 函数方法
const uploadsuccess = (e) => {
    if (e.success) {
        queryShopInfo()
    }

}

//查询店铺信息
const queryShopInfo = () => {
    $_shopInfo({ shopid }).then(res => {
        res.data.createtime = dayjs(res.data.createtime).format('YYYY-MM-DD HH:mm:ss')
        res.data.s_imgurl = res.data.s_imgurl ? baseImgURL + res.data.s_imgurl : delImgUrl
        shopInfo.value = res.data
    })
}
queryShopInfo()




</script>

<style lang="scss" scoped>
.add_title {
    margin-bottom: 24px;
}
</style>